package com.lsh.oms.provider.service.payment;

import com.alibaba.dubbo.config.annotation.Service;
import com.lsh.base.common.model.CommonResult;
import com.lsh.oms.api.service.payment.IPaymentRestService;
import com.lsh.oms.core.model.payment.BillPaymentInfo;
import com.lsh.oms.core.service.payment.core.PaymentService;
import com.lsh.oms.core.service.tool.Criteria;
import com.lsh.oms.core.service.tool.Pageable;

import javax.annotation.Resource;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;

@Path("payments")
@Service(protocol = "rest", timeout = 30000)
public class PaymentRestService implements IPaymentRestService {

    @Resource(name = "payment.service")
    private PaymentService paymentService;

    @GET
    @Produces({MediaType.APPLICATION_JSON})
    @Override
    public CommonResult<Pageable<BillPaymentInfo>> query(@Context UriInfo uriInfo,
                                                         @DefaultValue("1") @QueryParam("page") long page,
                                                         @DefaultValue("20") @QueryParam("page-limit") long limit) {
        return CommonResult.success(paymentService.query(Criteria.of(uriInfo), page, limit));
    }
}
